﻿using System;
using System.Collections.Generic;

public partial class Controls_FrontEnd_Content : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack) return;
        GetAbout();

    }


    private void GetAbout()
    {
        var news = new Business.News { NewsID = 1 }.NewsGetByNewsId();
        ltrTitle.Text = news.Title;
        ltrContent.Text = news.Summary;
        imgAvatar.ImageUrl = Business.Config.ApplicationUrl + "resources/images/upload/" + news.ImageUrl;

    }


    public string GetGrid()
    {
        var list = new List<Business.News>();
        var html = string.Empty;
        var count = list.Count % 2 == 0 ? list.Count : list.Count + 1;
        for (var index = 0; index < count; index += 2)
        {
            var rowcount = 1;
            html += "<div class=\"article_row\">" + Environment.NewLine;
            for (var rowindex = index; rowindex < count; rowindex++)
            {
                if (rowcount == 2) break;
                var url = Business.Config.ApplicationUrl + list[rowindex].TitleEn + ".html";
                html += "<div style=\"width: 49.95%; float: left;\" class=\"article_column column" + rowcount +
                        " cols2\">" + Environment.NewLine;
                html += "<div class=\"article_column_pad\">" + Environment.NewLine;
                html += "<h2 class=\"contentheading\">" + Environment.NewLine;
                html += "<a class=\"contentpagetitle\" href=\"" + url + "\">" + list[rowindex].Title + "</a>" + Environment.NewLine;
                html += "</h2>" + Environment.NewLine;
                html += "<div style=\"text-align: justify;\">" + Environment.NewLine;
                html += "<img width=\"150\" title=\"" + list[rowindex].Title +
                        "\" style=\"margin: 5px; float: left;\" src=\"" + Business.Config.ApplicationUrl + "resources/images/upload/" + list[rowindex].ImageUrl + "\" alt=\"" +
                        list[rowindex].Title + "\">" + Environment.NewLine;
                html += list[rowindex].Summary + Environment.NewLine;
                html += "</div>" + Environment.NewLine;
                html += "<p>" + Environment.NewLine;
                html +=
                    "<a class=\"readon\" href=\"" + url + "\">Read more...</a>" +
                    Environment.NewLine;
                html += "</p>" + Environment.NewLine;
                html += "</div>" + Environment.NewLine;
                html += "</div>" + Environment.NewLine;
                html += "<span class=\"article_separator\">&nbsp;</span>" + Environment.NewLine;
                rowcount++;

            }
            html += "<span class=\"row_separator\">&nbsp;</span>" + Environment.NewLine;
            html += "</div>" + Environment.NewLine;


        }
        return html;
    }
}